/**
 * 
 */
package com.itr.test;

import java.io.File;
import java.math.BigInteger;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import com.itr.beans.AddressType;
import com.itr.beans.AssesseeNameType;
import com.itr.beans.CreationInfoType;
import com.itr.beans.FormITR1Type;
import com.itr.beans.ITR;
import com.itr.beans.ITR1Type;
import com.itr.beans.ITRNameSpaceMapper;
import com.itr.beans.ObjectFactory;
import com.itr.beans.PersonalInfoType;
import com.itr.beans.PhoneType;

/**
 * @author rohit.kumar
 *
 */
public class JaxbTester {
	
	private static ObjectFactory _itrFactory =  new ObjectFactory();
	private static final String EXAMPLE_XML = "./exampleITR.xml";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ITR itrFormType = _itrFactory.createITR();
		ITR1Type itrType = _itrFactory.createITR1Type();
		
		CreationInfoType creationInfo = _itrFactory.createCreationInfoType();
		creationInfo.setSWCreatedBy("DITEXCEL");
		creationInfo.setSWVersionNo("R7");
		creationInfo.setXMLCreationDate("2012-06-24");
		creationInfo.setIntermediaryCity("Delhi");
		itrType.setCreationInfo(creationInfo);
		
		FormITR1Type formItr1 = _itrFactory.createFormITR1Type();
		formItr1.setAssessmentYear(new BigInteger("2012"));
		formItr1.setDescription("For Indls having Income from Salary, Pension, family pension and Interest");
		formItr1.setFormName("ITR-1");
		formItr1.setFormVer("Ver1.0");
		formItr1.setSchemaVer("Ver1.0");
		itrType.setFormITR1(formItr1);
		
		PersonalInfoType personInfo = _itrFactory.createPersonalInfoType();
		AssesseeNameType assessName = _itrFactory.createAssesseeNameType();
		assessName.setFirstName("Rohit");
		assessName.setMiddleName("Kumar");
		assessName.setSurNameOrOrgName("Choubey");
		personInfo.setAssesseeName(assessName);
		personInfo.setPAN("ALYPR5305A");
		AddressType address = _itrFactory.createAddressType();
		address.setResidenceNo("Flat No-722, Sai Raghwendra");
		address.setRoadOrStreet("Nallagandla");
		address.setLocalityOrArea("Seri Lingampally");
		address.setStateCode(new BigInteger("02"));
		address.setEmailAddress("rohitkumar86@hotmail.com");
		address.setMobileNo(new BigInteger("7207320108"));
		address.setPinCode(new BigInteger("500019"));
		address.setCityOrTownOrDistrict("Hyderabad");
		PhoneType phone = _itrFactory.createPhoneType();
		phone.setSTDcode("040");
		phone.setPhoneNo("30553456");
		address.setPhone(phone);
		personInfo.setAddress(address);
		personInfo.setDOB("1986-12-27");
		personInfo.setEmployerCategory("OTH");
		personInfo.setGender("M");
		personInfo.setStatus("I");
		itrType.setPersonalInfo(personInfo);
		
		itrFormType.setITR1(itrType);
		try {
		JAXBContext context = JAXBContext.newInstance(ITR.class);
		Marshaller m = context.createMarshaller();
		m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		m.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new ITRNameSpaceMapper());
		m.marshal(itrFormType, new File(EXAMPLE_XML));
		} catch(JAXBException jaxb) {
			jaxb.printStackTrace();
		}
		
	}

}
